package com.hd.trans.network.apiService

import com.hd.trans.network.bean.DataResponse
import com.hd.trans.network.bean.RCOcrConvert
import com.hd.trans.network.bean.RCOcrFileDownload
import com.hd.trans.network.bean.RCUploadPointPar
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Query

interface ApiV4Service {

    @POST("/api/v4/uploadpar")
    suspend fun uploadpar(@Body uploadparBean: RequestBody): RCUploadPointPar


    /**
     * 查询转换任务状态
     */
    @Headers("Keep-Alive:true")
    @FormUrlEncoded
    @POST("/api/v4/taskstate")
    suspend fun queryTaskState(
        @Field("tasktag") tasktag: String,
        @Field("ifshowtxt") ifshowtxt: Int,
        @Field("account") account: String?,
        @Field("usertoken") usertoken: String?
    ): RCOcrConvert


    @FormUrlEncoded
    @POST("/api/v4/taskdown")
    suspend fun downloadFile(
        @Field("tasktag") tasktag: String,
        @Field("account") account: String?,
        @Field("usertoken") usertoken: String?,
        @Field("downtype") downtype: Int = 2,//下载类型，取值范围：1（转换前），2（转换后）；默认2
        @Field("multiurl") multiurl: Int = 0 //是否下载时显示多个链接地址；取值范围0或1; 当显示多个地址时为1
    ): RCOcrFileDownload


    @Headers("Content-Type: application/octet-stream")
    @POST("""api/v4/uploadfile""")
    suspend fun uploadfile(
        @Query("tasktag") tasktag: String,
        @Query("timestamp") timestamp: String,
        @Query("tasktoken") tasktoken: String,
        @Query("chunk") chunk: Int,
        @Query("chunks") chunks: Int,
        @Query("fileindex") fileindex: Int = 0,
        @Body file: RequestBody
    ): DataResponse
}